﻿// -------------------------------------------------------------------------
//    @FileName         :    NFTransOpStoreageBag.h
//    @Author           :    Gao.Yi
//    @Date             :    2025-10-20
//    @Email			:    445267987@qq.com
//    @Module           :    NFTransOpStoreageBag
//    @Desc             :
//
// -------------------------------------------------------------------------

#pragma once

#include "NFTransPlayerBase.h"
#include "NFLogicCommon/NFItemDefine.h"

namespace proto_ff
{
    class Proto_CSStorageMoveReq;
    class Proto_CSBuyBagGridInfo;
}

class NFTransOpStoreageBag : public NF_OBJECT_TEMPLATE_MACRO(NFTransOpStoreageBag, EOT_TRANS_OP_STOREAGE_BAG, NFTransPlayerBase)
public:
    NFTransOpStoreageBag();
    ~NFTransOpStoreageBag() override;
    int CreateInit();
    int ResumeInit();
public:
    int HandleCSMsgReq(const google::protobuf::Message* pCsMsgReq) override;
    int HandleDispSvrRes(uint32_t nMsgId, const NFDataPackage& packet, uint32_t reqTransId, uint32_t rspTransId) override;
    int HandleTransFinished(int iRunLogicRetCode) override;
public:
    ///////////////////buy grid////////////////////////
    int HandleBuyBagGridReq(const proto_ff::Proto_CSBuyBagGridInfo* pReq);
    int HandleBuyBagGridPreRes(uint32_t nMsgId, const NFDataPackage& packet, uint32_t reqTransId, uint32_t rspTransId);
    int HandleBuyBagGridRes(uint32_t nMsgId, const NFDataPackage& packet, uint32_t reqTransId, uint32_t rspTransId);
    //////////////////save item to storage bag////////////////////////
    int OnHandleStorageSaveReq(const proto_ff::Proto_CSStorageMoveReq* pReq);
    int HandleStorageSavePreRes(uint32_t nMsgId, const NFDataPackage& packet, uint32_t reqTransId, uint32_t rspTransId);
    int HandleStorageSaveRes(uint32_t nMsgId, const NFDataPackage& packet, uint32_t reqTransId, uint32_t rspTransId);
    ///////////////////pick item from storage///////////////////////
    int OnHandlePickFromStorageReq(const proto_ff::Proto_CSStorageMoveReq* pReq);
    int HandleStoragePickStoragePreRes(uint32_t nMsgId, const NFDataPackage& packet, uint32_t reqTransId, uint32_t rspTransId);
    int HandleStoragePickStorageRes(uint32_t nMsgId, const NFDataPackage& packet, uint32_t reqTransId, uint32_t rspTransId);
private:
    int m_iBagPage;
    int m_iBuyTimes;
    int m_iItemId;
    int m_iItemNum;
    uint64_t m_iItemUUID;
    int m_iGridIndex;
    NFGridItem m_stItem;
};
